<?php

namespace Database\Seeders;

// use Illuminate\Database\Console\Seeds\WithoutModelEvents;
use Illuminate\Database\Seeder;

class DatabaseSeeder extends Seeder
{
    /**
     * Seed the application's database.
     */
    public function run(): void
    {
        $this->command->info('🚀 开始填充数据库...');
        
        // 基础数据（所有环境）
        $this->call(SystemSettingSeeder::class);
        $this->call(ProvinceSeeder::class);
        $this->call(CitySeeder::class);
        $this->call(DistrictSeeder::class);
        $this->call(UserSeeder::class);
        $this->call(CategorySeeder::class);
        $this->call(SpecificationAttributeSeeder::class);
        $this->call(SpecificationTemplateSeeder::class);
        $this->call(LogisticsCompanySeeder::class);
        $this->call(CouponSeeder::class);
        
        // 业务数据和测试数据（仅本地环境）
        if ($this->isLocalEnvironment()) {
            $this->command->info('');
            $this->command->info('📦 本地环境：填充业务和测试数据...');
            $this->call(ProductVariantSeeder::class);
            $this->call(UserAddressSeeder::class);
            //$this->call(OrderSeeder::class);
            //$this->call(AfterSalesSeeder::class);
        } else {
            $this->command->info('');
            $this->command->info('🌐 生产环境：跳过业务和测试数据');
        }
        
        $this->command->info('');
        $this->command->info('✅ 数据库填充完成！');
    }

    /**
     * 判断是否为本地环境
     */
    private function isLocalEnvironment(): bool
    {
        $environment = app()->environment();
        
        // 本地环境：local, testing, development
        $localEnvironments = ['local', 'testing', 'development'];
        
        return in_array($environment, $localEnvironments);
    }
}
